// bind函数的使用
#include <iostream>
#include <functional>
#include <unistd.h>
#include <string>
#include <vector>

//对于线程池
void print(const std::string& str)
{
    std::cout << str << std::endl;
}

int main()
{
    using func = std::function<void()>;
    std::vector<func> vf;
    vf.push_back(std::bind(print, "你好"));
    vf.push_back(std::bind(print, "halo"));
    vf.push_back(std::bind(print, "哈咯"));
    vf.push_back(std::bind(print, "md"));

    for(auto& e : vf)
    {
        e();
    }
    return 0;
}

/*class Task
{
public:
    Task()
    {
        std::cout << "Task 构造函数" << std::endl;
    }

    ~Task()
    {
        std::cout << "Task 析构函数" << std::endl;
    }
};

void Test(const Task* t,int num)
{
    std::cout << num << std::endl;
    delete t;
}

int main()
{
    Task *t = new Task;
    std::function<void(int)> bt = std::bind(Test, t, std::placeholders::_1);
    bt(1010);
    while(1)
    {
        sleep(1);
    }
    return 0;
}
*/